package com.alibaba.algo;

import java.util.ResourceBundle;

/**
 * config
 */
public class GCConfig {

    private static final ResourceBundle config = ResourceBundle.getBundle("config");

    /**
     * The diver name.
     */
    public static String DIVER_NAME;

    /**
     * The url.
     */
    public static String URL;

    /**
     * The username.
     */
    public static String USERNAME;

    /**
     * The password.
     */
    public static String PASSWORD;

    /**
     * The project path.
     */
    public static String PROJECT_PATH;

    /**
     * The maven path.
     */
    public static String MAVEN_PATH;

    /**
     * The bussi package.
     */
    public static String BUSSI_PACKAGE;
    /**
     * The bussi package.
     */
    public static String EXCLUDE_DOMAIN_COLUMN;

    /**
     * The domain package.
     */
    public static String DOMAIN_PACKAGE;
    public static String TABLE_PREFIX;
    public static String TABLE_SCHEMA;

    /**
     * The code path.
     */
    public static String CODE_PATH;

    /**
     * The mapper path.
     */
    public static String MAPPER_PATH;

    /**
     * The table id.
     */
    public static String TABLE_ID;

    /**
     * The table db id.
     */
    public static String TABLE_DB_ID;

    /**
     * The generate table.
     */
    public static String GENERATE_TABLE;

    /**
     * The geneate table class.
     */
    public static String GENEATE_TABLE_CLASS;

    /**
     * The product code.
     */
    public static String PRODUCT_CODE;

    /**
     * The product name.
     */
    public static String PRODUCT_NAME;

    /**
     * The version.
     */
    public static String VERSION;

    /**
     * The common pack path.
     */
    public static String COMMON_PACK_PATH;

    /**
     * The author.
     */
    public static String AUTHOR;

    /**
     * The store db.
     */
    public static String STORE_DB;

    static {
        TABLE_ID = "id";
        TABLE_DB_ID = "id";
        DIVER_NAME = getDIVER_NAME();
        URL = getURL();
        USERNAME = getUSERNAME();
        PASSWORD = getPASSWORD();
        GENERATE_TABLE = getGenerateTable();
        GENEATE_TABLE_CLASS = getGenerateTableClass();
        PRODUCT_CODE = getProductCode();
        PRODUCT_NAME = getProductName();
        AUTHOR = getAuthor();
        VERSION = getVersion();
        STORE_DB = getStoreDB();
        COMMON_PACK_PATH = getCommonPackPath();
        PROJECT_PATH = getProjectPath();
        MAVEN_PATH = getMavenPath();
        BUSSI_PACKAGE = getBussiPackage();
        TABLE_PREFIX = getTablePrefix();
        EXCLUDE_DOMAIN_COLUMN = getExculdeDomainCloumn();
        MAVEN_PATH = MAVEN_PATH.replace(".", "/");
        String bussiPackageUrl = BUSSI_PACKAGE.replace(".", "/");
        CODE_PATH = (new StringBuilder(String.valueOf(PROJECT_PATH))).append("/").append(MAVEN_PATH).append("/")
                .append(bussiPackageUrl).append("/").toString();
        MAPPER_PATH = new StringBuilder(PROJECT_PATH + "/" + getMapperPackage().replace(".", "/")).append("/")
                .toString();
    }

    /**
     * Gets the diver name.
     *
     * @return the diver name
     */
    public static final String getDIVER_NAME() {
        return config.getString("diver_name").trim();
    }


    /**
     * Gets the url.
     *
     * @return the url
     */
    public static final String getURL() {
        return config.getString("url").trim();
    }

    /**
     * Gets the username.
     *
     * @return the username
     */
    public static final String getUSERNAME() {
        return config.getString("username").trim();
    }

    /**
     * Gets the password.
     *
     * @return the password
     */
    public static final String getPASSWORD() {
        return config.getString("password").trim();
    }

    /**
     * Gets the database name.
     *
     * @return the database name
     */
    public static final String getDATABASE_NAME() {
        return config.getString("database_name").trim();
    }

    /**
     * Gets the bussi package.
     *
     * @return the bussi package
     */
    public static String getBussiPackage() {
        return config.getString("bussiness_package").trim();
    }

    private static String getExculdeDomainCloumn() {
        return config.getString("exclude_domain_column").trim();
    }

    private static String getTablePrefix() {
        return config.getString("table_prefix").trim();
    }

    public static String getTableSchema() {
        return config.getString("table_schema").trim();
    }

    /**
     * Gets the maven path.
     *
     * @return the maven path
     */
    public static String getMavenPath() {
        return config.getString("maven_path").trim();
    }

    /**
     * Gets the mapper package.
     *
     * @return the mapper package
     */
    public static final String getMapperPackage() {
        return config.getString("mapper_package").trim();
    }

    /**
     * Gets the generate module.
     *
     * @return the generate module
     */
    public static final String getGenerateModule() {
        return config.getString("generate_module").trim();
    }

    /**
     * Gets the generate table.
     *
     * @return the generate table
     */
    public static final String getGenerateTable() {
        return config.getString("generate_table").trim();
    }

    /**
     * Gets the generate table class.
     *
     * @return the generate table class
     */
    public static final String getGenerateTableClass() {
        return config.getString("geneate_table_class").trim();
    }

    /**
     * Gets the product code.
     *
     * @return the product code
     */
    public static final String getProductCode() {
        return config.getString("product_code").trim();
    }

    /**
     * Gets the version.
     *
     * @return the version
     */
    public static final String getVersion() {
        return config.getString("version").trim();
    }

    /**
     * Gets the common pack path.
     *
     * @return the common pack path
     */
    public static final String getCommonPackPath() {
        return config.getString("common_pack_path").trim();
    }

    /**
     * Gets the product name.
     *
     * @return the product name
     */
    public static final String getProductName() {
        return config.getString("product_name").trim();
    }

    /**
     * Gets the author.
     *
     * @return the author
     */
    public static final String getAuthor() {
        return config.getString("author").trim();
    }

    /**
     * Gets the store DB.
     *
     * @return the store DB
     */
    public static final String getStoreDB() {
        return config.getString("store_db").trim();
    }

    /**
     * Gets the project path.
     *
     * @return the project path
     */
    public static String getProjectPath() {
        return (new StringBuilder(String.valueOf(System.getProperty("user.dir").replace("\\", "/")))).toString();
    }

    /**
     * Gets the template path.
     *
     * @return the template path
     */
    // 获取模板路径
    public static String getTemplatePath() {
        String classPath = Thread.currentThread().getContextClassLoader().getResource("./").getPath();
        return (new StringBuilder(String.valueOf(classPath))).append("template").toString();
    }
}
